package demo;

import java.util.Scanner;

/**
 * @Author liangzai
 * @Description:
 */
public class Main {
    //X进制减法
    public static void main3(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int maxN = scanner.nextInt();
        int n = scanner.nextInt();
        long[] num1 = new long[n+1];
        for (int i = n; i >=1 ; i--) {
            num1[i] = scanner.nextLong();
        }
        int m = scanner.nextInt();
        long[] num2 = new long[n+1];
        for (int i = m; i >= 1; i--) {
            num2[i] = scanner.nextLong();
        }

        long mod = 1000000007l;
        long sum = 0;
        long now = 1l;
        for (int i = 1; i <= Math.max(n,m); i++) {
            sum = (sum+(num1[i] - num2[i])*now )%mod;
            now = (now)%mod*Math.min((Math.max (Math.max(num1[i],num2[i])+1,2) ),maxN)%mod;
        }

        System.out.println(sum%mod);
    }

    //汉诺塔
    //static int count = 0;
    public static void main2(String[] args) {
        fun('A','B','C', 3);
        //System.out.println(ret+count);
    }

    private static void fun(char A,char B, char C,int num) {
        if(num==1) {
            System.out.println(A+"->"+B+" ");
            return ;
        }
        fun(A, C, B, num-1);
        System.out.print(A+"->"+B+" ");
        fun(C, B, A, num-1);
    }

    public static void main1(String[] args) {
        long sum = 1;
        for (int i = 2; i <= 62; i++) {
            sum = sum*2+1;
        }
        System.out.println(sum);
        System.out.println("18446744073709551615");
    }

    //奇妙变换
    public static void main4(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int num = scanner.nextInt();
        System.out.println(calc(num));
    }

    private static long calc(int num) {
        if(num>10) {
            return (2*num*calc(num-6))%998244353 ;
        }else {
            return (num*(num-1))%998244353;
        }
    }
}
